﻿using System.Windows.Forms;
using Com.OpenCode.Framework.Core;
using DevExpress.XtraBars;

namespace Com.OpenCode.Framework.DevForm
{
    /// <summary>
    ///     工具条。
    /// </summary>
    public class ToolBarMenuUI : OpenCodeToolBarMenuUI, IToolBarMenuProperty
    {
        /// <summary>
        ///     构造函数。
        /// </summary>
        /// <param name="args"></param>
        public ToolBarMenuUI(BuildItemEventArgs args)
        {
            args.Plugin.Owner = this;
            Manager = new OpenCodeBarManagerUI() { Form = args.Owner as Control };
            Manager.Bars.Add(this);
            ((System.ComponentModel.ISupportInitialize)(Manager)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(Manager)).EndInit();
            OwnerToolBarMenuUI = this;
        }

        public OpenCodeToolBarMenuUI OwnerToolBarMenuUI { get; set; }
        public bool BeginGroup { get; set; }

        public void Add(BarItem item)
        {
            item.Manager = Manager;
            AddItem(item).BeginGroup = BeginGroup;
        }
    }
}